package com.anlu.concurrent.ch5.bq;

import java.util.concurrent.DelayQueue;

/**
 * <p>
 * Description:TODO 详细描述
 * <p>
 * Copyright: 天津联想协同科技有限公司
 * <p>
 *
 * @author anlu
 * @date 2021/10/27 16:38
 */
public class PutOrder implements  Runnable{

    private DelayQueue<ItemVo<Order>> queue;

    public PutOrder(DelayQueue<ItemVo<Order>> queue) {
        this.queue = queue;
    }

    @Override
    public void run() {

        //5秒到期
        Order orderTb = new Order("01",366);
        ItemVo<Order> itemTb = new ItemVo<>(5000,orderTb);
        queue.offer(itemTb);
        System.out.println("订单5秒后到期："+orderTb.getOrderNo());

        //8秒到期
        Order ordeJd = new Order("Jd54321",366);
        ItemVo<Order> itemJd = new ItemVo<Order>(8000,ordeJd);
        queue.offer(itemJd);
        System.out.println("订单8秒后到期："+ordeJd.getOrderNo());
    }
}
